package com.luoke.handler.response;

import com.luoke.connect.GameWebSocketClient;
import com.luoke.constants.SubmoduleTypeConstant;
import com.luoke.service.response.UserResponseService;
import com.luoke.service.response.impl.UserResponseServiceImpl;
import com.luoke.result.Result;

/**
 * 用户响应处理层，负责响应的分发
 */
public class UserResponseHandler {

    private UserResponseService userResponseService = new UserResponseServiceImpl();


    public void handler(GameWebSocketClient gameWebSocketClient, Result result) {

        //这里进行分发到对应的service层
        if (result.getCommand().equals(SubmoduleTypeConstant.USER_LOGIN)){
            //处理用户登录的响应
            userResponseService.userLogin(gameWebSocketClient,result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.USER_REGISTER)){
            //处理用户注册的响应
            userResponseService.userRegister(gameWebSocketClient,result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.USER_LOGOUT)){
            //处理用户退出的响应
            userResponseService.userLogout(gameWebSocketClient,result);
        }else if (result.getCommand().equals(SubmoduleTypeConstant.BAG)){
            userResponseService.showBag(gameWebSocketClient,result);
        }else if (result.getCommand().equals(SubmoduleTypeConstant.PETS)){
            userResponseService.showPets(gameWebSocketClient,result);
        }else if(result.getCommand().equals(SubmoduleTypeConstant.SHOP)) {
            userResponseService.showShop(gameWebSocketClient,result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.BUY)) {
            userResponseService.handleBuy(gameWebSocketClient,result);
        }else if (result.getCommand().equals(SubmoduleTypeConstant.MAP)) {
            userResponseService.showMap(gameWebSocketClient,result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.SHOW_USER_ONLINE_NAME)) {
            userResponseService.showUserOnlineName(gameWebSocketClient,result);

        } else if (result.getCommand().equals(SubmoduleTypeConstant.PVE)) {
            userResponseService.toHandlePetFetch(gameWebSocketClient,result);
        }


    }
}
